package com.stockz.ui.swing.charting.display.indicator;

import java.awt.Graphics2D;
import java.util.List;

import org.springframework.stereotype.Component;

import com.stockz.core.util.BarUtil.BarValueType;
import com.stockz.indicator.movingAverage.simple.SimpleMovingAverageIndicator;
import com.stockz.indicator.stochastics.StochasticsIndicator;
import com.stockz.indicator.vsa.VsaBar;
import com.stockz.indicator.vsa.VsaIndicator;
import com.stockz.ui.swing.charting.painter.indicator.VsaIndicatorPainter;
import com.stockz.ui.swing.charting.util.UIChartingConstant.OVERLAY;

@Component

public class VolumeSpreadAnalysis extends AbstractDisplayableIndicatorConfiguration {

	private VsaIndicator vsaIndicator = new VsaIndicator(new SimpleMovingAverageIndicator(), new StochasticsIndicator());
	
	private String fullName = "Volume Spread Analysis";
	private String shortName = "VSA";
	private List<VsaBar> vsaBarList;

	@Override
	public BarValueType getBarValueType() {
		return vsaIndicator.getBarValueType();
	}
	
	@Override
	public void setBarValueType(BarValueType barValueType) {
		vsaIndicator.setBarValueType(barValueType);
	}

	@Override
	public String getFullName() {
		return fullName;
	}

	@Override
	public String getShortName() {
		return shortName;
	}

	@Override
	public void refreshValues() {
		vsaBarList = vsaIndicator.convert(getStockChartPanel().getStockChartPanelState().getBarList());
	}

	@Override
	public String getDescription() {
		return getShortName();
	}

	@Override
	public void paint(Graphics2D g) {
		VsaIndicatorPainter.paint(g, this);
	}
	
	@Override
	public boolean isOverlappable() {
		return true;
	}

	@Override
	public OVERLAY getOverlay() {
		return OVERLAY.PRICE;
	}

	public List<VsaBar> getVsaBarList() {
		return vsaBarList;
	}
	
	@Override
	public Object getConfiguration() {
		return vsaIndicator.getIndicatorConfiguration();
	}
}

